package com.pr.springbootthmeleaf.com.controll;

import com.pr.springbootthmeleaf.com.bean.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("th")
public class IndexController {

    @RequestMapping("/hello/thymeleaf")
    public String hello(Model model) {
        model.addAttribute("msg", "springboot集成thymeleaf");

        User user = new User();
        user.setId(1);
        user.setName("张三");
        user.setAge(10);
        model.addAttribute("user", user);
        return "test";
    }

    @GetMapping("/index")
    public String index(ModelMap map) {
        map.addAttribute("name", "thymeleaf-index");
        return "index";
    }
}
